package com.test.antisamy;

import org.owasp.validator.html.AntiSamy;
import org.owasp.validator.html.CleanResults;
import org.owasp.validator.html.Policy;

import java.io.InputStream;


public class AntiSamyDemo {

    public static void main(String[] args) throws Exception {
        AntiSamyDemo demo = new AntiSamyDemo();
        demo.demo1();
    }

    public void demo1() throws Exception{
        InputStream is = getClass().getClassLoader().getResourceAsStream("antisamy-ebay.xml");
        String xsshtml = "hyf<script>alert(1)</script>&nbsp;\"gogo\"";
        Policy policy = Policy.getInstance(is);
        AntiSamy antiSamy = new AntiSamy();
        CleanResults cr = antiSamy.scan(xsshtml,policy);
        xsshtml = cr.getCleanHTML();
        System.out.println(xsshtml);
    }

}
